package com.snailct.bpp.service.client.support;

import com.snailct.bpp.commons.protocol.HTTPUtil;
import com.snailct.bpp.commons.protocol.RespResult;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.joda.time.DateTime;

import java.util.HashMap;
import java.util.Map;

public class HttpServiceInvoker extends DefaultServiceInvoker {
    private static final Log logger = LogFactory.getLog(HttpServiceInvoker.class);
    protected RespResult request(String reqXml) {
        long currentTimeMillis = System.currentTimeMillis();
        Map<String,String> params = new HashMap<String,String>();
        params.put("reqData",reqXml);
        RespResult respResult = HTTPUtil.request(params,this.getReqURL());
        if (!respResult.getStatus().name().equals(RespResult.ReqStatus.OK.name())) {
            logger.error("连接后台URL:" + this.getReqURL() + "请求失败！");
            return null;
        }
        logger.info("请求完成:" + "请求时间:"
                + (System.currentTimeMillis() - currentTimeMillis) + " ms");
        return respResult;
    }

}
